/*
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-05-11 18:11:41
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-01-30 15:23:05
 * @FilePath: /hr_new_vue3/src/apis/management/human/humanChange/leave/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/* 人事-基础设置-离职管理列表api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL = env.VITE_API_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL = 'http://192.168.31.129:39001';
// const baseURL2 = 'http://192.168.31.129:39003';
// const baseURL2 = 'http://192.168.31.129:39001';
const baseURL2 = env.VITE_APP_BASE_URL;

// 获取离职列表
export function GetLeaveManagementList(params: any) {
  return ajaxService({
    url: '/pl/leave/apply',
    method: 'get',
    baseURL: baseURL2,
    params
  });
}

// 获取离职列表表头
export function GetLeaveManagementListHeader() {
  return ajaxService({
    url: '/pl/leave/set/offboardingWords',
    method: 'get',
    baseURL: baseURL2
  });
}

// 获取人员花名册详情
export function GetHumanRosterDetail(params: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/list/detail',
    method: 'get',
    baseURL,
    params
  });
}

// 编辑人员花名册详情
export function PutHumanRosterDetail(data: any) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/personnel/list/detail',
      method: 'put',
      baseURL,
      data
    },
    {
      mode: 'success',
      message: '保存成功！'
    }
  );
}

// 获取离职交接详情
export function GetLeaveHandoverDetail(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/offboarding',
    method: 'get',
    baseURL,
    params
  });
}

// 编辑/新增离职交接
export function PostLeaveHandoverDetail(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/offboarding',
    method: 'post',
    baseURL,
    data
  });
}

// 删除离职交接所有表格里面数据的id
export function DelLeaveHandoverDetail(data: { ids: number[] }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/offboarding',
    method: 'delete',
    baseURL,
    data
  });
}

// 获取离职面谈记录详情（待离职列表）
export function GetLeaveInterViewListDetail(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/interview_sheet/sheet/template',
    method: 'get',
    baseURL,
    params
  });
}

// 新增离职面谈记录详情（待离职列表）
export function PostLeaveInterViewListDetail(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/interview_sheet/sheet/template',
    method: 'post',
    baseURL,
    data
  });
}

// 编辑离职面谈记录详情（待离职列表）
export function PutLeaveInterViewListDetail(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/interview_sheet/sheet/template',
    method: 'put',
    baseURL,
    data
  });
}

// 删除离职面谈记录详情里的问题（待离职列表）
export function DelLeaveInterViewListDetailProblem(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/interview_sheet/wenti',
    method: 'delete',
    baseURL,
    params
  });
}

// 编辑离职面谈记录详情里的问题（待离职列表）
export function PutLeaveInterViewListDetailProblem(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/interview_sheet/wenti',
    method: 'put',
    baseURL,
    data
  });
}

// 修改离职手续状态（同步到人员详情的接口）
export function PutLeaveProcedureStatus2Human(data: {
  id: number;
  status: 0 | 1 | 2; //0初始状态 1保存状态 2发起状态
}) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/produce/le',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 获取离职申请人员详情
export function GetLeaveApplyPersonnelDetail(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/movement',
    method: 'get',
    baseURL,
    params
  });
}

// 发起离职申请
export function PostLeaveApplyPersonnel(data: any) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/movement',
      method: 'post',
      baseURL,
      data
    },
    {
      mode: 'success',
      message: '提交成功！'
    }
  );
}

// 修改离职申请
export function PutLeaveApplyPersonnel(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/movement',
    method: 'put',
    baseURL,
    data
  });
}
